package it.multisystem.gettingstarted;

public class NotOOCalculator {

	public static int sum(int x, int y) {
		return x + y;
	}

	public static double multiply(double x, double y) {
		return x * y;
	}

	public static int multiSum(int... addends) {
		int sum = 0;
		// for (int i = 0; i < addends.length; i++) {
		// sum += addends[i];
		// }

		for (int current : addends) {
			sum += current;
		}
		return sum;
	}

	public static int sumFirstN(int n) {
		return n * (n + 1) / 2;
	}

	public static int fibonacci(int n) {
		if (n < 0) {
			throw new IllegalArgumentException(Integer.toString(n));
		}
		int result = 0;
//		if (n == 0 || n == 1) {
//			result = n;
//		} else {
//			result = fibonacci(n - 1) + fibonacci(n - 2);
//		}
		switch (n) {
			case 0:
			case 1: {
				result = n;
				break;
			}
			default: {
				result = fibonacci(n - 1) + fibonacci(n - 2);
			}
		}

		return result;
	}
}
